/*!
 * \file t_http_auth_parse.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"

#include "../../../../src/module/http/config.h"
#include <http/comm/http_comm.h>
#include <http/http_core.h>
#include <frct_comm.h>
#include "frreport_comm.h"
#include "../../../comm/apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __case1(void)
{
    Conntrack *p_st_conn = NULL;
    Frreport_body_data *p_st_body_data = NULL;
    char *p_data_in = NULL;
    L7session_http_private *p_st_private = NULL;
    int i_ret = 0;

    i_ret = apmtest_create_ct(&p_st_conn, http_session_destroy, (char *)"192.168.0.1", (char *)"192.168.0.35", 5460, 80);

    p_st_private = http_private_create();
    p_st_private->i_version = 1;
    p_st_private->p_http1_sess = http1_session_create();

    p_st_body_data = frreport_body_new_l7(p_st_conn);

    p_data_in = frstrdup((const char *)"Basic YWRtaW46YWRtaW4=");

    i_ret = http_auth_parse(p_st_body_data, p_data_in, p_st_private);
    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frfree(p_data_in);
    apmtest_destroy_ct(&p_st_conn);
    frreport_body_free(&p_st_body_data);
    http_session_destroy(p_st_private);

    return;
}

int add_suite_http_auth_parse(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" http_auth_parse()", __suite_init, __suite_cleanup)) == NULL)
    return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);

    return FR_SUCC;
}
